/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.cmu.cs.webapp.ioms.models.impl;

import edu.cmu.cs.webapp.ioms.models.IOMSPackage;
import edu.cmu.cs.webapp.ioms.models.LineItem;

import edu.cmu.cs.webapp.ioms.models.Product;
import edu.cmu.cs.webapp.ioms.models.PurchaseOrder;
import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Line Item</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.LineItemImpl#getItem_id <em>Item id</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.LineItemImpl#getQuantity <em>Quantity</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.LineItemImpl#getProduct <em>Product</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.LineItemImpl#getUnit <em>Unit</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.LineItemImpl#getRemark <em>Remark</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.LineItemImpl#getOrder <em>Order</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class LineItemImpl extends EObjectImpl implements LineItem {
	/**
	 * The default value of the '{@link #getItem_id() <em>Item id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItem_id()
	 * @generated
	 * @ordered
	 */
	protected static final int ITEM_ID_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getItem_id() <em>Item id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItem_id()
	 * @generated
	 * @ordered
	 */
	protected int item_id = ITEM_ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getQuantity() <em>Quantity</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getQuantity()
	 * @generated
	 * @ordered
	 */
	protected static final double QUANTITY_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getQuantity() <em>Quantity</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getQuantity()
	 * @generated
	 * @ordered
	 */
	protected double quantity = QUANTITY_EDEFAULT;

	/**
	 * The cached value of the '{@link #getProduct() <em>Product</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProduct()
	 * @generated
	 * @ordered
	 */
	protected Product product;

	/**
	 * The default value of the '{@link #getUnit() <em>Unit</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUnit()
	 * @generated
	 * @ordered
	 */
	protected static final String UNIT_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getUnit() <em>Unit</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUnit()
	 * @generated
	 * @ordered
	 */
	protected String unit = UNIT_EDEFAULT;

	/**
	 * The default value of the '{@link #getRemark() <em>Remark</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRemark()
	 * @generated
	 * @ordered
	 */
	protected static final String REMARK_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getRemark() <em>Remark</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRemark()
	 * @generated
	 * @ordered
	 */
	protected String remark = REMARK_EDEFAULT;

	/**
	 * The cached value of the '{@link #getOrder() <em>Order</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOrder()
	 * @generated
	 * @ordered
	 */
	protected PurchaseOrder order;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected LineItemImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return IOMSPackage.Literals.LINE_ITEM;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getItem_id() {
		return item_id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setItem_id(int newItem_id) {
		int oldItem_id = item_id;
		item_id = newItem_id;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.LINE_ITEM__ITEM_ID, oldItem_id, item_id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getQuantity() {
		return quantity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setQuantity(double newQuantity) {
		double oldQuantity = quantity;
		quantity = newQuantity;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.LINE_ITEM__QUANTITY, oldQuantity, quantity));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Product getProduct() {
		if (product != null && product.eIsProxy()) {
			InternalEObject oldProduct = (InternalEObject)product;
			product = (Product)eResolveProxy(oldProduct);
			if (product != oldProduct) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, IOMSPackage.LINE_ITEM__PRODUCT, oldProduct, product));
			}
		}
		return product;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Product basicGetProduct() {
		return product;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setProduct(Product newProduct) {
		Product oldProduct = product;
		product = newProduct;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.LINE_ITEM__PRODUCT, oldProduct, product));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getUnit() {
		return unit;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUnit(String newUnit) {
		String oldUnit = unit;
		unit = newUnit;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.LINE_ITEM__UNIT, oldUnit, unit));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getRemark() {
		return remark;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRemark(String newRemark) {
		String oldRemark = remark;
		remark = newRemark;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.LINE_ITEM__REMARK, oldRemark, remark));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PurchaseOrder getOrder() {
		if (order != null && order.eIsProxy()) {
			InternalEObject oldOrder = (InternalEObject)order;
			order = (PurchaseOrder)eResolveProxy(oldOrder);
			if (order != oldOrder) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, IOMSPackage.LINE_ITEM__ORDER, oldOrder, order));
			}
		}
		return order;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PurchaseOrder basicGetOrder() {
		return order;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOrder(PurchaseOrder newOrder) {
		PurchaseOrder oldOrder = order;
		order = newOrder;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.LINE_ITEM__ORDER, oldOrder, order));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case IOMSPackage.LINE_ITEM__ITEM_ID:
				return getItem_id();
			case IOMSPackage.LINE_ITEM__QUANTITY:
				return getQuantity();
			case IOMSPackage.LINE_ITEM__PRODUCT:
				if (resolve) return getProduct();
				return basicGetProduct();
			case IOMSPackage.LINE_ITEM__UNIT:
				return getUnit();
			case IOMSPackage.LINE_ITEM__REMARK:
				return getRemark();
			case IOMSPackage.LINE_ITEM__ORDER:
				if (resolve) return getOrder();
				return basicGetOrder();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case IOMSPackage.LINE_ITEM__ITEM_ID:
				setItem_id((Integer)newValue);
				return;
			case IOMSPackage.LINE_ITEM__QUANTITY:
				setQuantity((Double)newValue);
				return;
			case IOMSPackage.LINE_ITEM__PRODUCT:
				setProduct((Product)newValue);
				return;
			case IOMSPackage.LINE_ITEM__UNIT:
				setUnit((String)newValue);
				return;
			case IOMSPackage.LINE_ITEM__REMARK:
				setRemark((String)newValue);
				return;
			case IOMSPackage.LINE_ITEM__ORDER:
				setOrder((PurchaseOrder)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case IOMSPackage.LINE_ITEM__ITEM_ID:
				setItem_id(ITEM_ID_EDEFAULT);
				return;
			case IOMSPackage.LINE_ITEM__QUANTITY:
				setQuantity(QUANTITY_EDEFAULT);
				return;
			case IOMSPackage.LINE_ITEM__PRODUCT:
				setProduct((Product)null);
				return;
			case IOMSPackage.LINE_ITEM__UNIT:
				setUnit(UNIT_EDEFAULT);
				return;
			case IOMSPackage.LINE_ITEM__REMARK:
				setRemark(REMARK_EDEFAULT);
				return;
			case IOMSPackage.LINE_ITEM__ORDER:
				setOrder((PurchaseOrder)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case IOMSPackage.LINE_ITEM__ITEM_ID:
				return item_id != ITEM_ID_EDEFAULT;
			case IOMSPackage.LINE_ITEM__QUANTITY:
				return quantity != QUANTITY_EDEFAULT;
			case IOMSPackage.LINE_ITEM__PRODUCT:
				return product != null;
			case IOMSPackage.LINE_ITEM__UNIT:
				return UNIT_EDEFAULT == null ? unit != null : !UNIT_EDEFAULT.equals(unit);
			case IOMSPackage.LINE_ITEM__REMARK:
				return REMARK_EDEFAULT == null ? remark != null : !REMARK_EDEFAULT.equals(remark);
			case IOMSPackage.LINE_ITEM__ORDER:
				return order != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (item_id: ");
		result.append(item_id);
		result.append(", quantity: ");
		result.append(quantity);
		result.append(", unit: ");
		result.append(unit);
		result.append(", remark: ");
		result.append(remark);
		result.append(')');
		return result.toString();
	}

} //LineItemImpl
